
<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>普通资产管理</title>
		<link rel="stylesheet" href="../layui/css/layui.css">
		<script type="text/javascript" src="../js/jquery-3.4.1.min.js"></script>
		<script type="text/javascript" src="layui/layui.all.js"></script>
	</head>

	<body>
		<div class="layui-elem-quote">
			<span class="layui-breadcrumb">
				<a href="">首页</a>
                <a href="">资产流转管理</a>
                <a href=""><cite>普通资产流转管理</cite></a>
			</span>
		</div>
		<div>
			<form class="layui-form">
				<div class="layui-inline"> <label class="layui-form-label">资产操作：</label>
					<div class="layui-input-inline">
						<select id="selectId5">
								
							</select>

					</div>
				</div>

				<div class="layui-inline">
					<label class="layui-form-label">资产名称：</label>
					<div class="layui-input-inline">
						<input type="text" id="" class="layui-input" />
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label">批次编号：</label>
					<div class="layui-input-inline">
						<input type="text" id="" class="layui-input" />
					</div>
				</div>
				<div class="layui-inline">
					<div class="layui-input-inline">
						<a href="" class="layui-btn layui-btn-success"><span class="layui-icon layui-icon-search"></span>检索Search</a>
					</div>
				</div>
			</form>
		</div>

		<div class="layui-card">
			<div class="layui-card-header">
				可领用资产列表
			</div>
			<div class="layui-card-body">
			<table id="demo" lay-filter="test"></table>
		</div>
		<script type="text/html" id="toolbar1">
			<div>
				<a class="layui-btn layui-bg-blue" lay-event="add">
					<span class="layui-icon layui-icon-add-1"></span>新建资产 Add
				</a>
				<a class="layui-btn layui-bg-cyan" lay-event="delete">
					<span class="layui-icon layui-icon-download-circle"></span>资产入库 Instock
				</a>
				<a class="layui-btn layui-bg-orange" lay-event="edit">
					<span class="layui-icon layui-icon-edit"></span>编辑资产 Edit
				</a>

			</div>
		</script>

		<script src="layui/layui.js"></script>
		<script src="layui/layui.all.js"></script>
		<script>
			layui.use(['element', 'form', 'laypage', 'table', 'jquery'],
					function() {
						var element = layui.element;
						var $ = layui.$;
						var form = layui.form;
						var laypage = layui.laypage;
						var table = layui.table;
						table.render({
							elem: '#demo',
							url: 'dataJSON/paintAssetManage.json' //数据接口
								,
							toolbar: "#toolbar1",
							id: "test1",
							page: true //开启分页
								,
							limit: 5,
							limits: [5, 10, 15, 20],
							loading: false,
							done: function(res, curr, count) {
								console.log(res, curr, count);
							},
							cols: [
								[ //表头
									{
										type: "checkbox"
									}, {
										field: 'id',
										title: '资产名称',
										sort:true,
										width: 200
									}, {
										field: 'showValue',
										title: '批次编号',
										width: 260
									}, {
										field: 'class',
										title: '单价（￥）',
										width: 160,
									}, {
										field: 'desc',
										title: '当前库存量',
										width: 140
									}, {
										field: 'name',
										title: '采购人',
										width: 140
									}, {
										field: 'data',
										title: '入库日期',
										width: 180
									}, {
										field: "",
										title: '操作',
										templet: function(data) {
												var str1 = "<a lay-event='row_edit' href='javascript:;' class='layui-btn layui-bg-success'><span class='layui-icon layui-icon-template-1'></span>编辑</a>";
										
											return str1;
										}
									}

								]
							]
						});
							table.on("toolbar(test)", function(obj) {
						var data = obj.data;
						var event1 = obj.event;
						if(event1 === "add") {
							layer.open({
								title: "新建资产",
								area: ['600px', '600px'],
								content: $("#frm_add").html()
							});
							table.reload();
						}
						if(event1 === "delete") {
							var tbl_data =
								table.checkStatus("test1");
							var data = tbl_data.data;
							if(tbl_data .data.length == 0) {
								layer.alert("请选择一行数据");
							} else {
								alert(JSON.stringify(tbl_data.data[0].id));
							}
							table.reload();
						}
						if(event1 === "edit") {
							layer.open({
								title: "编辑资产",
								area: ['600px', '600px'],
								content: $("#frm_add").html()
							});
							table.reload();
						}
					});


					table.on("tool(test)", function(obj) {
						var myevent = obj.event;
						var data = obj.data;
						if(myevent == "row_edit") {
							layer.open({
								title: "新建资产",
								area: ['600px', '600px'],
								content: $("#frm_add").html()
							});
						
						}
						
						$("#uname").val(data.id);
						$("#upwd").val(data.showValue);
						$("#date").val(data.class);
						$("#min").val(data.desc);
						$("#max").val(data.name);
						$("#nx").val(data.data)
					});


					//下拉选数据
					 $(function(){
     	           $.ajax({
     		         type:"get",
     		          url:"dataJSON/paintAssetManage.json",
     		           success:function(result){
     			         var seoption="";
     			         $.each(result.select,function(index,value){
     				     seoption+="<option>"+value+"</option>";
     			         })
     			         $("#paintAssetManage").append(seoption);
     			        form.render();
     		            }
     	               });
     
                       })
				});


			function toIndex() {


				$('#mainFrame').load('welcome.html');
			}
		</script>
		<script type="text/html" id="frm_add">
			<div>
				资产名称：<input id="uname" type="text" class="layui-input" placeholder="请输入资产名称" /><br /> 批次单号：
				<input id="upwd" type="text" class="layui-input" placeholder="请输入批次单号" /><br />单价（￥）：
				<input id="date" type="text" class="layui-input" placeholder="请输入单价（￥）" /><br /> 当前库存量：
				<input id="min" type="text" class="layui-input" placeholder="请输入当前库存量" /><br />采购人： 
				<input id="max" type="text" class="layui-input" placeholder="请输入采购人" /><br>入库日期：
				<input id="nx" type="text" class="layui-input" placeholder="请输入入库日期" /><br>
			</div>


		</script>
		</script>
	</body>

</html>